package com.teradata;

import org.lionsoul.jcseg.tokenizer.core.*;

import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;

public class IopSaleWordSplit {

    private static final JcsegTaskConfig CONFIG = new JcsegTaskConfig(true);
    private static final ADictionary DIC = DictionaryFactory.createDefaultDictionary(CONFIG);


    static {
        CONFIG.setLoadCJKSyn(false);
        CONFIG.setLoadCJKPinyin(false);
        CONFIG.setClearStopwords(true);
    }

    private Map<String, String> segMore(String text) {
        Map<String, String> map = new HashMap();

        map.put("复杂模式", segText(text, JcsegTaskConfig.COMPLEX_MODE));
        map.put("简易模式", segText(text, JcsegTaskConfig.SIMPLE_MODE));

        return map;
    }

    public String segText(String text, int segMode) {
        StringBuilder result = new StringBuilder();
        try {
            ISegment seg = SegmentFactory.createJcseg(segMode, new Object[]{new StringReader(text), CONFIG, DIC});
            IWord word = null;
            while ((word = seg.next()) != null) {
                if(word.getPartSpeech()!=null && !"v".equalsIgnoreCase(word.getPartSpeech()[0])){
                    result.append(word.getValue()).append(" ");
                }
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        return result.toString();
    }

    public static void main(String[] args) {
        IopSaleWordSplit i=new IopSaleWordSplit();
        System.out.println(i.segText("中秋月圆，祝福团圆！还在给你的好友群发祝福信息吗？那你就out啦！移动光宽带鱼好吃，飞信让您免费短信随时发，畅聊无限，指间传精彩，祝福“飞”出来！回复“KTFX”即可开通，点击下载客户端 http://go.10086.cn/g/vzn5ha",1));
    }
}
